{extend name="base" /} {block name="body"}
{block name="css"}
	<link rel="stylesheet" href="/public/oem/css/iconfont.css" />
	<link rel="stylesheet" href="/public/oem/css/css.css" />
{/block}

<div class="layui-body">
	<div class="navbar">
		<a><cite>商家联盟</cite></a>&nbsp;<span class="layui-box">&gt;</span>
		<a href=""><cite>商家列表</cite></a>
	</div>
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="layui-this">商家管理</li>
			<li class="">
				<a href="{:url('agent/add')}">添加商家</a>
			</li>
		</ul>
		<div class="layui-tab-content">
			<form class="layui-form layui-form-pane" action="{:url('agent/index')}" method="get">
				<div class="layui-inline">
					<label class="layui-form-label">关键词</label>
					<div class="layui-input-inline">
						<input type="text" name="keyword" value="{$keyword}" placeholder="请输入关键词" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<select name="ziduan">
						<option value="id" {if $ziduan=='id' }selected{/if}>商家ID</option>
						<option value="mobile" {if $ziduan=='mobile' }selected{/if}>商家账号</option>
						<option value="agent_name" {if $ziduan=='agent_name' }selected{/if}>商家名称</option>
					</select>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">商家分类</label>
					<div class="layui-input-inline">
					      <select name="goodstype"   class="layui-input">
					        <option value=""></option>
							{volist name="type_list" id="vo"}
							<option value="{$vo.id}">{$vo.name}</option>
							{/volist}
					      </select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">排序</label>
					<div class="layui-input-inline">
						<select name="param">
							<option value="add_time" {if $param=='add_time' }selected{/if}>注册时间</option>
							<option value="sort" {if $param=='sort' }selected{/if}>序号</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<select name="sort">
						<option value="asc" {if $sort=='asc' }selected{/if}>从低到高</option>
						<option value="desc" {if $sort=='desc' }selected{/if}>从高到底</option>
					</select>
				</div>
				<div class="layui-inline">
					<button class="layui-btn">搜索</button>
				</div>
			</form>
			<hr>
			<table class="layui-table">
				<thead>
					<tr>
						<th>ID</th>
						<th>账号(手机号)</th>
						<th style="width: 150px;">二维码 | 名称</th>
						<th>商家分类</th>
						<th>地址</th>
						<th>注册时间</th>
						<th>赠送票</th>
						<th>排序</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{foreach name="agent_list" item="vo"}
					<tr>
						<td>{$vo.id}</td>
						<td>{$vo.mobile}</td>
						<td><a class="iconfont icon-erweima"  href="javascript:;" onclick="ewm('{$vo.id}')"></a>&nbsp;{$vo.agent_name}</td>
						<td>{$vo.typename}</td>
						<td>{$vo.address}</td>						
						<td>{$vo.add_time}</td>
						<td><a class="iconfont icon-erweima"  href="javascript:;" onclick="zsewm('{$vo.id}')"></a>&nbsp;{$vo.givenum}</td>
						<td>{$vo.sort}</td>
						<td>
							<!--<a href="javascript:;" onclick="agent_give('赠送票','{:url('agent/give',['id'=>$vo.id])}','350','250')" class="layui-btn layui-btn-normal layui-btn-small">赠送票</a>-->
							<a href="javascript:;" onclick="agent_give('{$vo.id}')" class="layui-btn layui-btn-normal layui-btn-small">赠送票</a>
							<a href="{:url('agent/edit',['id'=>$vo['id']])}" class="layui-btn layui-btn-normal layui-btn-small">编辑</a>
							<a ref="delete_item?id={$vo.id}" class="layui-btn layui-btn-danger layui-btn-small confirm">删除</a>
						</td>
					</tr>
					{/foreach}
				</tbody>
			</table>
			<!--分页-->
			{$agent_list->render()}
		</div>
	</div>
</div>
<script>
	// 定义全局JS变量
	var GV = {
		current_controller: "{$controller}/index"
	};
</script>
{/block}
{block name="js"}
<script type="text/javascript" src="/public/static/js/H-ui.admin.js"></script>
<script>
	function ewm(agent_id) {
		var url = 'ewm?agent_id='+agent_id;
		layer.open({
		  type: 2,
		  title: '商家二维码',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['438px', '688px'],
		  content: [url]
		}); 
	}

	//赠送设置
	function agent_give(agent_id) {
		var url = 'give?id='+agent_id;
		layer.open({
		  type: 2,
		  title: '商家免费票赠送',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['350px', '250px'],
		  content: [url]
		}); 
	}
	
	/*会员编辑*/
//	function agent_give(title, url, w, h) {
//		layer_show(title, url, w, h);
//	}
	
	function zsewm(agent_id) {
		var url = 'zsewm?agent_id='+agent_id;
		layer.open({
		  type: 2,
		  title: '商家免费票领取二维码',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['438px', '520px'],
		  content: [url]
		}); 
	}
</script>
{/block}